
import UIKit

class MYGMeetingDetailViewController: MYGBaseController {
    var meetings:[MYGMeetingRoomListModel] = []
    override func viewDidLoad() {
        super.viewDidLoad()
        configUI()
    }
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        let barBtnItem:UIBarButtonItem = UIBarButtonItem(customView: backBtn)
        self.navigationItem.leftBarButtonItem = barBtnItem
    }
    private func configUI(){
        self.title = "查看会议"
        view.backgroundColor = .rgba(243, 243, 243)
        // 通过UIColor对象设置导航栏的背景颜色
        navigationController?.navigationBar.barTintColor = UIColor.clear
        navigationController?.navigationBar.titleTextAttributes = [.foregroundColor: UIColor.white]
        view.addSubview(headImageV)
        headImageV.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.height.equalTo(statusBarHeight + 44)
            make.top.equalToSuperview().offset(-statusBarHeight - 44)
        }
        view.addSubview(scheduleTable)
        scheduleTable.snp.makeConstraints { make in
            make.left.top.right.bottom.equalToSuperview()
        }
    }
    private lazy var scheduleTable: UITableView = {
        let cont = UITableView(frame: CGRectZero, style: .grouped)
        cont.delegate = self
        cont.dataSource = self
        cont.separatorStyle = .none
        cont.backgroundColor = .clear
        cont.register(cellWithClass: MYGMeetingDetailTableViewCell.self)

        return cont
    }()
    private lazy var headImageV:UIImageView = {
        let cont = UIImageView()
        cont.image = UIImage(named: "schedule_head")
        return cont
    }()    //MARK: lazy
    lazy var backBtn: UIButton = {
        let control = UIButton(type: .custom)
        control.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
        control.tintColor = .white
        control.setImage(UIImage(named: "Chat/back"), for: .normal)
        control.addTarget(self, action: #selector(backAction), for: .touchUpInside)
        return control
    }()
}

extension MYGMeetingDetailViewController:UITableViewDelegate,UITableViewDataSource{
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 0.01
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        let vi = UIView()
        return vi
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return meetings.count
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 194
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withClass: MYGMeetingDetailTableViewCell.self, for: indexPath)
        cell.selectionStyle = .none
        cell.model = meetings[indexPath.row]
        return cell
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let vc = MYGMeetingListDetailViewController()
        vc.mod = meetings[indexPath.row]
        self.navigationController?.pushViewController(vc)
    }
}
